diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-07 19:17:14 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-10-07 19:17:14 +0200 |
| commit | 66939bab93cdcb9b7732c45d7bc3b99b6951fe15 (patch) | |
| tree | ec6bc1631464410f8735da49e02e99abff0f3863 /src/routes/grocery/[id]/+page.server.ts | |
| parent | 6e5dcdb53cea4c3f082d01c937fe5fc1d580c45b (diff) | |
feat: promote a reference as the primary shown in lists
Add an is_primary flag to references; the promoted ref sorts first on the item page and is the one shown under the item in the list and catalog. Item page gets a star toggle per reference.
Diffstat (limited to 'src/routes/grocery/[id]/+page.server.ts')
| -rw-r--r-- | src/routes/grocery/[id]/+page.server.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/routes/grocery/[id]/+page.server.ts b/src/routes/grocery/[id]/+page.server.ts index 656e19c..a4ad377 100644 --- a/src/routes/grocery/[id]/+page.server.ts +++ b/src/routes/grocery/[id]/+page.server.ts @@ -6,10 +6,11 @@ import { loadAll as loadCategories } from '$lib/server/services/categories'; import { loadForGrocery, add as addRef, + promote, deleteReference, } from '$lib/server/services/references'; import { updateGrocery, deleteGrocery } from '$lib/server/services/groceries'; -import { deleteByIdAction } from '$lib/server/services/grocery-actions'; +import { idAction } from '$lib/server/services/grocery-actions'; import { numericId, parseFormString, @@ -70,7 +71,9 @@ export const actions: Actions = { }, delete: ({ request }) => - deleteByIdAction(request, deleteReference, { type: 'delete' }), + idAction(request, deleteReference, { type: 'delete' }), + + promote: ({ request }) => idAction(request, promote, { type: 'promote' }), update: async ({ request, params }) => { const data = await request.formData(); |
